<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul>
    <li>aaa</li>
    <li>bbb</li>
    <li>ccc</li>
  </ul>

  <script src="./jquery-3.6.0.js"></script>
  <script>
    // 点击 li ，希望得到这个 li 的索引
    // let lis = document.querySelectorAll('li');

    // for (let i = 0; i < lis.length; i++) {
    //   lis[i].onclick = function () {
    //     console.log(i);
    //   }
    // }


    $('li').click(function () {
      console.log($(this).index())
    });
  </script>
</body>

</html>